package com.tencent.iov.cowin.befsale.clue.controller.clue;

import com.tencent.iov.cowin.befsale.clue.controller.clue.assembler.ClueOrderAssembler;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.AddClueOrderRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.DeleteClueOrderRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.QueryClueOrderRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.UpdateClueOrderRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.response.ClueOrderResponse;
import com.tencent.iov.cowin.befsale.clue.domain.clue.po.ClueOrder;
import com.tencent.iov.cowin.befsale.clue.service.clue.ClueOrderService;
import com.software.boot.common.entity.Response;
import com.software.boot.common.model.dao.PageRequest;
import com.software.boot.common.model.dao.PageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Describe: 线索订单表_Controller层
 * @author: whp
 * @created: 2021-12-21 16:16:18
 * @version: 1.0
 */
@RestController
@Api(tags = "线索订单表Controller")
@RequestMapping(value = "/v1/clueOrder", produces = MediaType.APPLICATION_JSON_VALUE)
public class ClueOrderController {

    @Autowired
    private ClueOrderService clueOrderService;

    /**
     * 通过ID获取详细信息
     *
     * @param: id
     * @return: ClueOrder对象
     */
    @ApiOperation(value = "ClueOrder管理-通过ID获取详细信息接口", httpMethod = "GET", response = Response.class, notes = "get_detail_by_id")
    @RequestMapping(path = "/get_detail_by_id", method = RequestMethod.GET)
    public Response<ClueOrderResponse> getDetailById(@ApiParam(required = true, value = "对象ID", defaultValue = "1") @RequestParam("id") Long id) {
        return Response.success(ClueOrderAssembler.transformPOToResponseVo(clueOrderService.getDetailById(id), ClueOrderResponse.class));
    }

    /**
     * 单条数据插入ClueOrder
     *
     * @param request
     * @return 插入的条数
     */
    @ApiOperation(value = "ClueOrder管理-添加信息接口", httpMethod = "POST", response = Response.class, notes = "add")
    @RequestMapping(path = "/add", method = RequestMethod.POST)
    public Response<Integer> add(@Valid @RequestBody AddClueOrderRequest request) {
        return Response.success(clueOrderService.insert(ClueOrderAssembler.transformVOToPO(request, ClueOrder.class)));
    }

    /**
     * 批量插入ClueOrder
     *
     * @param requests
     * @return 批量插入的条数
     */
    @ApiOperation(value = "ClueOrder管理-批量插入ClueOrder接口", httpMethod = "POST", response = Response.class, notes = "add_batch")
    @RequestMapping(path = "/add_batch", method = RequestMethod.POST)
    public Response<Integer> addBatch(@Valid @RequestBody List<QueryClueOrderRequest> requests) {
        return Response.success(clueOrderService.insertBatch(ClueOrderAssembler.transformPOToResponseVoList(requests, ClueOrder.class)));
    }

    /**
     * 通过ID修改信息接口
     *
     * @param: request
     * @return: 修改的条数
     */
    @ApiOperation(value = "ClueOrder管理-修改信息接口", httpMethod = "POST", response = Response.class, notes = "update")
    @RequestMapping(path = "/update", method = RequestMethod.POST)
    public Response<Integer> update(@Valid @RequestBody UpdateClueOrderRequest request) {
        return Response.success(clueOrderService.update(ClueOrderAssembler.transformVOToPO(request, ClueOrder.class)));
    }

    /**
     * 通过ID删除数据
     *
     * @param request
     * @return 删除的条数
     */
    @ApiOperation(value = "ClueOrder管理-通过ID删除接口", httpMethod = "POST", response = Response.class, notes = "delete")
    @RequestMapping(path = "/delete", method = RequestMethod.POST)
    public Response<Integer> delete(@Valid @RequestBody DeleteClueOrderRequest request) {
        return Response.success(clueOrderService.delete(ClueOrderAssembler.transformVOToPO(request, ClueOrder.class)));
    }

    /**
     * 根据条件查询对象list列表
     *
     * @param request
     * @return 查询结果
     */
    @ApiOperation(value = "ClueOrder管理-根据条件查询对象list列表接口", httpMethod = "POST", response = Response.class, notes = "query_list_by_param")
    @RequestMapping(path = "/get_list_by_param", method = RequestMethod.POST)
    public Response<List<ClueOrderResponse>> getListByParam(@RequestBody QueryClueOrderRequest request) {
        List<ClueOrder> responseList = clueOrderService.getListByParam(ClueOrderAssembler.transformVOToPO(request, ClueOrder.class));
        return Response.success(ClueOrderAssembler.transformPOToResponseVoList(responseList, ClueOrderResponse.class));
    }

    /**
     * 根据条件查询对象Page记录
     *
     * @param request
     * @return 查询结果
     */
    @ApiOperation(value = "ClueOrder管理-根据条件查询对象Page记录接口", httpMethod = "POST", response = Response.class, notes = "get_page_by_param")
    @RequestMapping(value = "/get_page_by_param", method = RequestMethod.POST)
    public Response<PageResponse<ClueOrderResponse>> getPageByParam(@RequestBody PageRequest<QueryClueOrderRequest> request) {
        PageResponse<ClueOrder> clueOrderPageResponse = clueOrderService.getPageByParam(ClueOrderAssembler.transformVOToPOPage(request, ClueOrder.class));
        return Response.success(ClueOrderAssembler.transformPOToResponseVoPage(clueOrderPageResponse, ClueOrderResponse.class));
    }
}